package c.e.a.c.t;

import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.Path.Op;
import android.graphics.PointF;
import android.graphics.RectF;
import c.e.a.c.t.m.f;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Objects;

/* compiled from: ShapeAppearancePathProvider */
public class k {
    public final m[] a = new m[4];
    public final Matrix[] b = new Matrix[4];
    public final Matrix[] c = new Matrix[4];
    public final PointF d = new PointF();
    public final Path e = new Path();
    public final Path f = new Path();
    public final m g = new m();
    public final float[] h = new float[2];
    public final float[] i = new float[2];
    public boolean j = true;

    /* compiled from: ShapeAppearancePathProvider */
    public interface a {
    }

    public k() {
        for (int i = 0; i < 4; i++) {
            this.a[i] = new m();
            this.b[i] = new Matrix();
            this.c[i] = new Matrix();
        }
    }

    public void a(j jVar, float f, RectF rectF, a aVar, Path path) {
        Object obj;
        float[] fArr;
        float[] fArr2;
        j jVar2 = jVar;
        float f2 = f;
        RectF rectF2 = rectF;
        Path path2 = path;
        path.rewind();
        this.e.rewind();
        this.f.rewind();
        this.f.addRect(rectF2, Direction.CW);
        int i = 0;
        while (i < 4) {
            c cVar;
            if (i == 1) {
                cVar = jVar2.g;
            } else if (i == 2) {
                cVar = jVar2.h;
            } else if (i != 3) {
                cVar = jVar2.f;
            } else {
                cVar = jVar2.e;
            }
            if (i == 1) {
                obj = jVar2.c;
            } else if (i == 2) {
                obj = jVar2.d;
            } else if (i != 3) {
                obj = jVar2.b;
            } else {
                obj = jVar2.a;
            }
            m mVar = this.a[i];
            Objects.requireNonNull(obj);
            obj.a(mVar, 90.0f, f2, cVar.a(rectF2));
            int i2 = i + 1;
            float f3 = (float) (i2 * 90);
            this.b[i].reset();
            PointF pointF = this.d;
            if (i == 1) {
                pointF.set(rectF2.right, rectF2.bottom);
            } else if (i == 2) {
                pointF.set(rectF2.left, rectF2.bottom);
            } else if (i != 3) {
                pointF.set(rectF2.right, rectF2.top);
            } else {
                pointF.set(rectF2.left, rectF2.top);
            }
            Matrix matrix = this.b[i];
            PointF pointF2 = this.d;
            matrix.setTranslate(pointF2.x, pointF2.y);
            this.b[i].preRotate(f3);
            fArr = this.h;
            m[] mVarArr = this.a;
            fArr[0] = mVarArr[i].c;
            fArr[1] = mVarArr[i].d;
            this.b[i].mapPoints(fArr);
            this.c[i].reset();
            matrix = this.c[i];
            fArr2 = this.h;
            matrix.setTranslate(fArr2[0], fArr2[1]);
            this.c[i].preRotate(f3);
            i = i2;
        }
        i = 0;
        while (i < 4) {
            float abs;
            f fVar;
            float[] fArr3 = this.h;
            m[] mVarArr2 = this.a;
            fArr3[0] = mVarArr2[i].a;
            fArr3[1] = mVarArr2[i].b;
            this.b[i].mapPoints(fArr3);
            if (i == 0) {
                fArr3 = this.h;
                path2.moveTo(fArr3[0], fArr3[1]);
            } else {
                fArr3 = this.h;
                path2.lineTo(fArr3[0], fArr3[1]);
            }
            this.a[i].c(this.b[i], path2);
            if (aVar != null) {
                obj = this.a[i];
                Matrix matrix2 = this.b[i];
                c.e.a.c.t.g.a aVar2 = (c.e.a.c.t.g.a) aVar;
                BitSet bitSet = g.this.d;
                Objects.requireNonNull(obj);
                bitSet.set(i, false);
                f[] fVarArr = g.this.b;
                obj.b(obj.f);
                fVarArr[i] = new l(obj, new ArrayList(obj.h), matrix2);
            }
            int i3 = i + 1;
            int i4 = i3 % 4;
            float[] fArr4 = this.h;
            m[] mVarArr3 = this.a;
            fArr4[0] = mVarArr3[i].c;
            fArr4[1] = mVarArr3[i].d;
            this.b[i].mapPoints(fArr4);
            fArr4 = this.i;
            mVarArr3 = this.a;
            fArr4[0] = mVarArr3[i4].a;
            fArr4[1] = mVarArr3[i4].b;
            this.b[i4].mapPoints(fArr4);
            fArr4 = this.h;
            float f4 = fArr4[0];
            float[] fArr5 = this.i;
            float max = Math.max(((float) Math.hypot((double) (f4 - fArr5[0]), (double) (fArr4[1] - fArr5[1]))) - 0.001f, 0.0f);
            fArr4 = this.h;
            mVarArr3 = this.a;
            fArr4[0] = mVarArr3[i].c;
            fArr4[1] = mVarArr3[i].d;
            this.b[i].mapPoints(fArr4);
            if (i == 1 || i == 3) {
                abs = Math.abs(rectF.centerX() - this.h[0]);
            } else {
                abs = Math.abs(rectF.centerY() - this.h[1]);
            }
            this.g.e(0.0f, 0.0f, 270.0f, 0.0f);
            if (i == 1) {
                fVar = jVar2.k;
            } else if (i == 2) {
                fVar = jVar2.l;
            } else if (i != 3) {
                fVar = jVar2.j;
            } else {
                fVar = jVar2.i;
            }
            fVar.a(max, abs, f2, this.g);
            Path path3 = new Path();
            this.g.c(this.c[i], path3);
            if (this.j && (b(path3, i) || b(path3, i4))) {
                path3.op(path3, this.f, Op.DIFFERENCE);
                fArr = this.h;
                m mVar2 = this.g;
                fArr[0] = mVar2.a;
                fArr[1] = mVar2.b;
                this.c[i].mapPoints(fArr);
                path3 = this.e;
                fArr2 = this.h;
                path3.moveTo(fArr2[0], fArr2[1]);
                this.g.c(this.c[i], this.e);
            } else {
                this.g.c(this.c[i], path2);
            }
            if (aVar != null) {
                m mVar3 = this.g;
                Matrix matrix3 = this.c[i];
                c.e.a.c.t.g.a aVar3 = (c.e.a.c.t.g.a) aVar;
                BitSet bitSet2 = g.this.d;
                int i5 = i + 4;
                Objects.requireNonNull(mVar3);
                bitSet2.set(i5, false);
                f[] fVarArr2 = g.this.c;
                mVar3.b(mVar3.f);
                fVarArr2[i] = new l(mVar3, new ArrayList(mVar3.h), matrix3);
            }
            i = i3;
        }
        path.close();
        this.e.close();
        if (!this.e.isEmpty()) {
            path2.op(this.e, Op.UNION);
        }
    }

    public final boolean b(Path path, int i) {
        Path path2 = new Path();
        this.a[i].c(this.b[i], path2);
        RectF rectF = new RectF();
        path.computeBounds(rectF, true);
        path2.computeBounds(rectF, true);
        path.op(path2, Op.INTERSECT);
        path.computeBounds(rectF, true);
        if (!rectF.isEmpty()) {
            return true;
        }
        if (rectF.width() <= 1.0f || rectF.height() <= 1.0f) {
            return false;
        }
        return true;
    }
}
